package com.kc.data.scenic.controller;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.kc.data.common.base.R;
import com.kc.data.common.core.controller.BaseController;
import com.kc.data.common.domain.model.BizGoods;
import com.kc.data.common.domain.model.KcTest;
import com.kc.data.common.page.TableDataInfo;
import com.kc.data.common.service.IBizGoodsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @ClassName TestController
 * @Description TODO
 * @Author wangdongliang
 * @Date 2021/6/11 8:39
 */
@RestController
@Slf4j
public class TestController extends BaseController {
    @Resource
    private IBizGoodsService goodsService;
    @GetMapping("/test1")
    public R test(){
        log.info("接口调用成功");
        Map<String,String> map = new HashMap<>();
        map.put("name","zhangsan");
        return R.ok(map);
    }

    @GetMapping("/getInfo/{id}")
    public R getInfo(@PathVariable("id") Integer id){
        log.info("模拟详情接口,接收到的参数{}",id);
        Map<String,Integer> map = new HashMap<>();
        map.put("id",id);
        return R.ok(map);
    }

    @PostMapping("/add")
    public R add(@RequestBody @Valid KcTest kcTest){
        log.info("模拟添加数据，接收到的参数{}",kcTest);
        return R.ok(kcTest);
    }

    @PostMapping("/getList")
    public TableDataInfo getList(BizGoods bizGoods){
        log.info("模拟商品列表");
        startPage();
        List<BizGoods> goodsList = goodsService.getList(bizGoods);
        log.info("商品列表{}",goodsList);
        log.info("cccccccccccccccc{}",getDataTable(goodsList));
        return getDataTable(goodsList);
    }





}
